package com.example.teatea.controller;

import com.example.teatea.dao.CheckGood;
import com.example.teatea.dao.CheckMember;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.stage.Modality;
import javafx.stage.Stage;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

public class SettleAccountController{
    public TextField phone;
    public Button settleBt;
    public static String p;

    public void toSettle(ActionEvent actionEvent) throws IOException {
        if(!phone.getText().equals("") && !new CheckMember().checkMember(phone.getText())){
            Alert alert=new Alert(Alert.AlertType.INFORMATION);
            alert.setHeaderText("该会员不存在，请重新输入！");
            alert.show();
        }else{
            p = phone.getText();
            Stage stage1 = (Stage) settleBt.getScene().getWindow();
            stage1.close();
            FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/com/example/teatea/fxml/Settle.fxml"));
            Scene scene = new Scene(fxmlLoader.load());
            Stage stage = new Stage();
            stage.setScene(scene);
            //设置窗口标题
            stage.setTitle("结账");
            //设置窗体不关闭不能使用其它窗体
            stage.initModality(Modality.APPLICATION_MODAL);
            //设置窗口大小不能改变
            stage.setResizable(false);
            stage.show();
        }

    }
}
